### conative attitudes matrix showing action/inaction pairs:

##ENDLINE
#Subset lab data to  relevant variables, note that randomdraw6_grouped is four categories, showing 
# which of the four sets of passive options the respondent was offered 
aggregate(randomdraw6 ~ randomdraw6_grouped, lab, range) #just check the grouping is right
aggregate(randomdraw6 ~ abs_passive_option_lc1, lab, range) #just check the grouping is right
lab_compliers_absonly <- lab[,c(
	"randomdraw6_grouped","lc1","bring_up","pta","assemble",
	"abs_passive_option_lc1","abs_passive_option_bring_up",
	"abs_passive_option_pta","abs_passive_option_assemble",
	"absenteeism")] #Make temp matrix of absentee conative data 

#create table for both treatment and control
col1 <- c(
	mean(subset(lab_compliers_absonly, abs_passive_option_lc1=="tutor")$lc1),
	mean(subset(lab_compliers_absonly, abs_passive_option_lc1=="headmaster")$lc1),
	mean(subset(lab_compliers_absonly, abs_passive_option_lc1=="wait")$lc1),
	mean(subset(lab_compliers_absonly, abs_passive_option_lc1=="send")$lc1)) 
col2 <- c(
	mean(subset(lab_compliers_absonly, abs_passive_option_bring_up=="tutor")$bring_up),
	mean(subset(lab_compliers_absonly, abs_passive_option_bring_up=="headmaster")$bring_up),
	mean(subset(lab_compliers_absonly, abs_passive_option_bring_up=="wait")$bring_up),
	mean(subset(lab_compliers_absonly, abs_passive_option_bring_up=="send")$bring_up))
col3 <- c(
	mean(subset(lab_compliers_absonly, abs_passive_option_pta=="tutor")$pta),
	mean(subset(lab_compliers_absonly, abs_passive_option_pta=="headmaster")$pta),
	mean(subset(lab_compliers_absonly, abs_passive_option_pta=="wait")$pta),
	mean(subset(lab_compliers_absonly, abs_passive_option_pta=="send")$pta))
col4 <- c(
	mean(subset(lab_compliers_absonly, abs_passive_option_assemble=="tutor")$assemble),
	mean(subset(lab_compliers_absonly, abs_passive_option_assemble=="headmaster")$assemble),
	mean(subset(lab_compliers_absonly, abs_passive_option_assemble=="wait")$assemble),
	mean(subset(lab_compliers_absonly, abs_passive_option_assemble=="send")$assemble))
action_df_lab <- data.frame(cbind(col1,col2,col3,col4))
action_df_lab <- cbind(c(Passive_Option),action_df_lab)
action_df_lab$treatment <- "all"

rm(col1,col2,col3,col4)
rm(lab_compliers_absonly)


###make tables ready for publication
action_df_lab$treatment <- NULL
action_df_lab$`c(Passive_Option)` <- NULL
rownames(action_df_lab) <- c("Find a tutor","Ask headmaster","Wait","Neighbouring village")
colnames(action_df_lab) <- c("Involve LC1 Chair","Tell village","Use PTA","Assemble group")

#bold total row of overall table
action_df_lab <- round(action_df_lab,2)
rownames(action_df_lab) <- c("Find a tutor","Ask headmaster","Wait","Neighbouring village")

#make conative attitude matrix tables

action_df_lab_xtable <- xtable(action_df_lab, digits=2, caption = "Conative attitudes among participants of lab-in-the field experiment, by passive and active options offered (N = 689)", label = "table:conative_attitudes_matrix_lab")
align(action_df_lab_xtable) <- "|l|c|c|c|c|"
sink("03_tables/ABS_lab_conative_attitudes_matrix.tex")
print(action_df_lab_xtable)
sink()



